using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Data.Models.Mapping
{
    public class ToolNormMap : EntityTypeConfiguration<ToolNorm>
    {
        public ToolNormMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("ToolNorm");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Level).HasColumnName("Level");
            this.Property(t => t.Date1).HasColumnName("Date1");
            this.Property(t => t.Date2).HasColumnName("Date2");
            this.Property(t => t.UOMID).HasColumnName("UOMID");
            this.Property(t => t.Norm).HasColumnName("Norm");
            this.Property(t => t.ToolTypeID).HasColumnName("ToolTypeID");

            // Relationships
            this.HasOptional(t => t.ToolType)
                .WithMany(t => t.ToolNorms)
                .HasForeignKey(d => d.ToolTypeID);
            this.HasOptional(t => t.UOM)
                .WithMany(t => t.ToolNorms)
                .HasForeignKey(d => d.UOMID);

        }
    }
}
